package com.twu.biblioteca;

public class Movie{

    private int id;
    private String name;
    private int year;
    private String director;
    private float rating;
    private int noOfCopies;



    public Movie(int id, String name, int year, String director, float rating, int noOfCopies) {
        this.id = id;
        this.name = name;
        this.year = year;
        this.director = director;
        this.rating = rating;
        this.noOfCopies = noOfCopies;
    }

    public boolean isAvailable() {
        return (noOfCopies>0);
    }

    public boolean checkOutCopy() {
        if(noOfCopies>0){
            noOfCopies--;
            return true;
        }

        return false;
    }

    public boolean returnCopy(){
        noOfCopies++;
        return true;
    }

    @Override
    public String toString() {
        return id + "\t" + name + "\t" + year + "\t" + director + "\t" + rating;
    }
}
